package www.openteam.com.presenter.business;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.InsertStatus;
import www.openteam.com.contract.business.UpdateCustomInfoContract;
import www.openteam.com.model.business.UpdateCustomInfoModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.UpdateCustomInfoFragment;

/**
 * Created by kylin on 2016/10/20.
 */

public class UpdateCustomInfoPresenter extends BasePresenter<UpdateCustomInfoFragment>
        implements UpdateCustomInfoContract.UpdateCustomInfoPresenter {
    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new UpdateCustomInfoModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {

        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("updateCutomInfo", models[0]);


        return hashMap;
    }

    @Override
    public void updateCustomInfo(String code, String name, String type, String paytime, String moneytype, String SendAddress, String connecter, String BusinessMan, String CreditNumb, String cTel, int id) {
        if (!getIView().checkNull()) {
            ((UpdateCustomInfoModel) getiModelMap().get("updateCutomInfo"))
                    .updateCustomInfo(code, name, type, paytime, moneytype
                            , SendAddress, connecter, BusinessMan, CreditNumb, cTel
                            , id, new UpdateCustomInfoModel.UpdateCustomInfoOnListener() {
                                @Override
                                public void updateCISuccess(InsertStatus insertStatus) {
                                    getIView().updateCIData(insertStatus);
                                }

                                @Override
                                public void updateCIFail(Throwable throwable) {
                                    getIView().hideCIData(throwable);
                                }
                            });
        }
    }
//    public void updateCustomInfo(String code, String name,
//                          String type, String paytime,
//                          String moneytype, String SendAddress,
//                          String connecter, String BusinessMan,
//                          String CreditNumb, String cTel,int id);


}
